/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.dp1.pucp.Compras.VIsta;


import com.dp1.pucp.Modelo.Clases.Costoinsumos;
import com.dp1.pucp.Modelo.Clases.Proveedor;
import com.dp1.pucp.Modelo.Clases.Tipoproducto;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import javax.swing.JFrame;
import javax.swing.table.DefaultTableModel;
/**
 *
 * @author tupapi.com
 */
public class ProdxProvGUI extends javax.swing.JDialog {
    
    /**
     * Creates new form UsuarioGUI
     */
    
    private JFrame padre;
    
//    public BuscarMateriaPrimaGUI materiaPrima;
    
    
    public JFrame getPadre(){ return padre; }
    
    public ProdxProvGUI(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
        this.setTitle("Productos por Proveedor");
        setLocationRelativeTo(null);
    }
    
    public void setFormCliente(Proveedor u){
        if (u!=null){
        /*    txtNombre.setText(u.getNombre());
            txtMaterno.setText(u.getApellidomaterno());
            txtApPaterno.setText(u.getApellidopaterno());
            txtDNI.setText(String.valueOf(u.getDni()));
            txtCorreo.setText(u.getEmail());
            txtDireccion.setText(u.getDireccion());
            txtTelefono.setText(String.valueOf(u.getTelefono()));*/
        }
    }
    

   public void listaCostos(ArrayList<Costoinsumos> lista){
       if (lista!=null){
             ((DefaultTableModel) this.tblResultados.getModel()).setRowCount(0);
            for (int i = 0; i<lista.size();i++){
                ((DefaultTableModel) tblResultados.getModel()).setRowCount(tblResultados.getRowCount()+1);
                tblResultados.setValueAt(lista.get(i).getTipoproducto().getNombre(),i,0);
                tblResultados.setValueAt(lista.get(i).getCosto(),i,1);
                tblResultados.setValueAt(lista.get(i).getFechainicio(),i,2);
                tblResultados.setValueAt(lista.get(i).getFechafin(),i,3);
                
                
               
             }
        }
   }
  /*  public void mostrarAviso(String msn){
        Validaciones.mostrarMensajeAvisoVal(msn);   
    }
    public void mostrarError(String msn){
        Validaciones.mostrarMensajeErrorVal(msn);           
    }
    public int solicitarConfirmacion(String msn){
        return Validaciones.solicitarConfirmacionVal(msn);
    } */   
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel2 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        tblResultados = new javax.swing.JTable();
        btnAgregarProd = new javax.swing.JButton();
        btnCancelar = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Productos por Proveedor", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Ubuntu", 0, 15))); // NOI18N

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 641, Short.MAX_VALUE)
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 214, Short.MAX_VALUE)
        );

        tblResultados.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "PRODUCTO", "PRECIO", "FECHA  INICIO", "FECHA  FIN"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        tblResultados.getTableHeader().setResizingAllowed(false);
        tblResultados.getTableHeader().setReorderingAllowed(false);
        jScrollPane1.setViewportView(tblResultados);

        btnAgregarProd.setFont(new java.awt.Font("Ubuntu", 0, 10)); // NOI18N
        btnAgregarProd.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/edit2.png"))); // NOI18N
        btnAgregarProd.setText("Agregar Producto");
        btnAgregarProd.setBorderPainted(false);
        btnAgregarProd.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnAgregarProd.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM);
        btnAgregarProd.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnAgregarProd.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAgregarProdActionPerformed(evt);
            }
        });

        btnCancelar.setFont(new java.awt.Font("Ubuntu", 0, 10)); // NOI18N
        btnCancelar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/Activar.png"))); // NOI18N
        btnCancelar.setText("Aceptar");
        btnCancelar.setContentAreaFilled(false);
        btnCancelar.setHideActionText(true);
        btnCancelar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnCancelar.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM);
        btnCancelar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(27, 27, 27)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 605, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(45, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(btnAgregarProd)
                .addGap(18, 18, 18)
                .addComponent(btnCancelar)
                .addGap(26, 26, 26))
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(41, 41, 41)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 194, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(27, 27, 27)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(btnAgregarProd, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(btnCancelar, javax.swing.GroupLayout.Alignment.TRAILING))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(98, Short.MAX_VALUE)))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnAgregarProdActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAgregarProdActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_btnAgregarProdActionPerformed

    public void LimpiarDatos(){
      /*  txtNombre.setText("");
        txtCorreo.setText("");
        txtApPaterno.setText("");
        txtDNI.setText("");
        txtMaterno.setText("");
        txtDireccion.setText("");*/
    }
    
    public void addAgregarProdListener(ActionListener ml)
    { this.btnAgregarProd.addActionListener(ml);}
    
//    public void addLimpiarListener(ActionListener ml){
//        this.btnLimpiar.addActionListener(ml);
//    }
//        
//    public void addGuardarListener(ActionListener ml){
//        this.btnGuardar.addActionListener(ml);
//    }
//    
    public void addCancelarListener(ActionListener ml){
        this.btnCancelar.addActionListener(ml);
    }     
//    
    /**
     * @param args the command line arguments
     */
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnAgregarProd;
    private javax.swing.JButton btnCancelar;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable tblResultados;
    // End of variables declaration//GEN-END:variables
}
